{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 商城管理
    <span class="c-gray en">&gt;</span> 订单列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="/shop/order_list" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px;margin-right: 10px"  id="daochu" title="&nbsp;&nbsp;导出&nbsp;&nbsp;" >导出</a>
</nav>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            <span class="select-box" style="width: 100px;">
                <select name="select_type" class="select">
                    <option value="-1">查询条件</option>
                    <option value="1" {if isset($_GET['select_type']) && $_GET['select_type'] == 1}selected{/if}>订单号</option>
                    <option value="2" {if isset($_GET['select_type']) && $_GET['select_type'] == 2}selected{/if}>收件人手机号</option>
                    <option value="3" {if isset($_GET['select_type']) && $_GET['select_type'] == 3}selected{/if}>快递单号</option>
                </select>
            </span>
            <input type="text" value="{:input('get.keyword')}" name="keyword" class="input-text" style="width:160px;">

            订单时间：
            <input type="text" onfocus="WdatePicker()" value="{:input('get.start')}" name="start" id="datemin" class="input-text Wdate" style="width:120px;" autocomplete="off">
            -
            <input type="text" onfocus="WdatePicker()" value="{:input('get.end')}" name="end" id="datemax" class="input-text Wdate" style="width:120px;" autocomplete="off">

            <span class="select-box" style="width: 100px;">
                <select name="status" class="select">
                    <option value="-1">全部状态</option>
                    <option value="0" {if isset($_GET['status']) && $_GET['status'] == 0}selected{/if}>待发货</option>
                    <option value="1" {if isset($_GET['status']) && $_GET['status'] == 1}selected{/if}>已发货</option>
                    <option value="2" {if isset($_GET['status']) && $_GET['status'] == 2}selected{/if}>确认收货</option>
                </select>
            </span>
            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l" style="color: red;">总兑换券数量:{$total_ticket}</span>
        <span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="12">订单列表</th>
        </tr>
        <tr class="text-c">
            <th width="20">id</th>
            <th width="110">订单号</th>
            <th width="100">商品</th>
            <th width="50">价格(兑换卷)</th>
            <th width="80">买家</th>
            <th width="150">收件地址</th>
            <th width="80">创建时间</th>
            <th width="80">发货时间</th>
            <th width="80">快递单号</th>
            <th width="80">备注</th>
            <th width="50">状态</th>
            <th width="80">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
            <td style="text-align: center">{$v.id}</td>
            <td>{$v.order_id}</td>
            <td style="text-align: center">{$v.name}</td>
            <td>{$v.price}</td>
            <td>昵称：{$v.nickname}</br>
                手机：{$v.mobile}
            </td>
            <td>收件人:&nbsp&nbsp{$v.receive_name}</br>
                电话:&nbsp&nbsp{$v.mobile}</br>
                {$v.province}{$v.city}{$v.area}{$v.address}
            </td>
            <td>{$v.create_time}</td>
            <td>{$v.send_time}</td>
            <td>{$v.courier_num}</td>
            <td>{$v.remark}</td>
            <td>{switch name="$v.status"}
                {case value="0"}待发货
                <a class="btn btn-default radius" title="发货" href="javascript:;" onclick="shipments(1,{$v.id})"><i class="Hui-iconfont">&#xe603;</i></a>
                {/case}
                {case value="1"}已发货
                <a class="btn btn-default radius" title="修改订单号" href="javascript:;" onclick="shipments(2,{$v.id})"><i class="Hui-iconfont">&#xe6df;</i></a>
                {/case}
                {case value="2"}确认收货{/case}
                {default /}--
                {/switch}</td>
            <td>
                <a class="btn btn-default radius good_del" title="删除" href="javascript:;" onclick="del({$v.id})"><i class="Hui-iconfont">&#xe609;</i></a>
            </td>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$list->render()|raw}
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">

    var url = window.location.href;
    if(url.indexOf("shop.mtao.vip") >= 0 ) { //判断url地址中是否包含link字符串
        $(".good_del").hide()
    }
    //调出发货页面
    function shipments(type,id){
        layer.open({
            type: 2,
            title: '发货',
            area: ['450px', '255px'],
            fixed: false, //不固定
            maxmin: true,
            content: "shipments.html?ids="+id,
            end:function(){
                location.reload();
            },
            success: function(layero, index){
                //从父页面给自页面赋值
                var jquerySendHelloButton = $('#typeid', layero.find("iframe")[0].contentWindow.document);
                jquerySendHelloButton.attr("value", type);

                var jquerySendHelloButton = $('#id', layero.find("iframe")[0].contentWindow.document);
                jquerySendHelloButton.attr("value", id);


            },
        });
    }

    /*商品上下架*/
    function del(id) {
        var tip = '确认要删除吗？';
        layer.confirm(tip,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('del_order')}",
                data:{'id':id},
                dataType: 'json',
                success: function(res){
                    if(res.status == 1){
                        layer.msg(res.info,{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.reload();
                        });
                    }else{
                        layer.msg(res.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(res) {
                    console.log(res.info);
                },
            });
        });

    }

    $("#daochu").bind("click",function () {
        window.location.href="/report/shoporderexcel.html?"+$("#qfrom").serialize()

    })
</script>
